﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using TicketManager.Entities;
using TicketManager.Data;

#endregion

namespace TicketManager.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="VeProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class VeProviderBaseCore : EntityProviderBase<TicketManager.Entities.Ve, TicketManager.Entities.VeKey>
	{		
		#region Get from Many To Many Relationship Functions
		#region GetByUserIdFromLichSuGdkh
		
		/// <summary>
		///		Gets ve objects from the datasource by UserID in the
		///		lich_su_GDKH table. Table ve is related to table user
		///		through the (M:N) relationship defined in the lich_su_GDKH table.
		/// </summary>
		/// <param name="_userId"></param>
		/// <returns>Returns a typed collection of Ve objects.</returns>
		public TList<Ve> GetByUserIdFromLichSuGdkh(System.Int32 _userId)
		{
			int count = -1;
			return GetByUserIdFromLichSuGdkh(null,_userId, 0, int.MaxValue, out count);
			
		}
		
		/// <summary>
		///		Gets TicketManager.Entities.Ve objects from the datasource by UserID in the
		///		lich_su_GDKH table. Table ve is related to table user
		///		through the (M:N) relationship defined in the lich_su_GDKH table.
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_userId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Ve objects.</returns>
		public TList<Ve> GetByUserIdFromLichSuGdkh(System.Int32 _userId, int start, int pageLength)
		{
			int count = -1;
			return GetByUserIdFromLichSuGdkh(null, _userId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Ve objects from the datasource by UserID in the
		///		lich_su_GDKH table. Table ve is related to table user
		///		through the (M:N) relationship defined in the lich_su_GDKH table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_userId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of ve objects.</returns>
		public TList<Ve> GetByUserIdFromLichSuGdkh(TransactionManager transactionManager, System.Int32 _userId)
		{
			int count = -1;
			return GetByUserIdFromLichSuGdkh(transactionManager, _userId, 0, int.MaxValue, out count);
		}
		
		
		/// <summary>
		///		Gets Ve objects from the datasource by UserID in the
		///		lich_su_GDKH table. Table ve is related to table user
		///		through the (M:N) relationship defined in the lich_su_GDKH table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_userId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of ve objects.</returns>
		public TList<Ve> GetByUserIdFromLichSuGdkh(TransactionManager transactionManager, System.Int32 _userId,int start, int pageLength)
		{
			int count = -1;
			return GetByUserIdFromLichSuGdkh(transactionManager, _userId, start, pageLength, out count);
		}
		
		/// <summary>
		///		Gets Ve objects from the datasource by UserID in the
		///		lich_su_GDKH table. Table ve is related to table user
		///		through the (M:N) relationship defined in the lich_su_GDKH table.
		/// </summary>
		/// <param name="_userId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of ve objects.</returns>
		public TList<Ve> GetByUserIdFromLichSuGdkh(System.Int32 _userId,int start, int pageLength, out int count)
		{
			
			return GetByUserIdFromLichSuGdkh(null, _userId, start, pageLength, out count);
		}


		/// <summary>
		///		Gets ve objects from the datasource by UserID in the
		///		lich_su_GDKH table. Table ve is related to table user
		///		through the (M:N) relationship defined in the lich_su_GDKH table.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <param name="_userId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a TList of Ve objects.</returns>
		public abstract TList<Ve> GetByUserIdFromLichSuGdkh(TransactionManager transactionManager,System.Int32 _userId, int start, int pageLength, out int count);
		
		#endregion GetByUserIdFromLichSuGdkh
		
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, TicketManager.Entities.VeKey key)
		{
			return Delete(transactionManager, key.VeId);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="_veId">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Int32 _veId)
		{
			return Delete(null, _veId);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_veId">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Int32 _veId);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_ghe key.
		///		FK_ve_ghe Description: 
		/// </summary>
		/// <param name="_gheId"></param>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByGheId(System.Int32 _gheId)
		{
			int count = -1;
			return GetByGheId(_gheId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_ghe key.
		///		FK_ve_ghe Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gheId"></param>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		/// <remarks></remarks>
		public TList<Ve> GetByGheId(TransactionManager transactionManager, System.Int32 _gheId)
		{
			int count = -1;
			return GetByGheId(transactionManager, _gheId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_ghe key.
		///		FK_ve_ghe Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gheId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByGheId(TransactionManager transactionManager, System.Int32 _gheId, int start, int pageLength)
		{
			int count = -1;
			return GetByGheId(transactionManager, _gheId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_ghe key.
		///		fkVeGhe Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_gheId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByGheId(System.Int32 _gheId, int start, int pageLength)
		{
			int count =  -1;
			return GetByGheId(null, _gheId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_ghe key.
		///		fkVeGhe Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_gheId"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByGheId(System.Int32 _gheId, int start, int pageLength,out int count)
		{
			return GetByGheId(null, _gheId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_ghe key.
		///		FK_ve_ghe Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_gheId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public abstract TList<Ve> GetByGheId(TransactionManager transactionManager, System.Int32 _gheId, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_loaive key.
		///		FK_ve_loaive Description: 
		/// </summary>
		/// <param name="_loaiVeId"></param>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByLoaiVeId(System.Int32 _loaiVeId)
		{
			int count = -1;
			return GetByLoaiVeId(_loaiVeId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_loaive key.
		///		FK_ve_loaive Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_loaiVeId"></param>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		/// <remarks></remarks>
		public TList<Ve> GetByLoaiVeId(TransactionManager transactionManager, System.Int32 _loaiVeId)
		{
			int count = -1;
			return GetByLoaiVeId(transactionManager, _loaiVeId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_loaive key.
		///		FK_ve_loaive Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_loaiVeId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByLoaiVeId(TransactionManager transactionManager, System.Int32 _loaiVeId, int start, int pageLength)
		{
			int count = -1;
			return GetByLoaiVeId(transactionManager, _loaiVeId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_loaive key.
		///		fkVeLoaive Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_loaiVeId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByLoaiVeId(System.Int32 _loaiVeId, int start, int pageLength)
		{
			int count =  -1;
			return GetByLoaiVeId(null, _loaiVeId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_loaive key.
		///		fkVeLoaive Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_loaiVeId"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByLoaiVeId(System.Int32 _loaiVeId, int start, int pageLength,out int count)
		{
			return GetByLoaiVeId(null, _loaiVeId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_loaive key.
		///		FK_ve_loaive Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_loaiVeId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public abstract TList<Ve> GetByLoaiVeId(TransactionManager transactionManager, System.Int32 _loaiVeId, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_phim key.
		///		FK_ve_phim Description: 
		/// </summary>
		/// <param name="_phimId"></param>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByPhimId(System.Int32 _phimId)
		{
			int count = -1;
			return GetByPhimId(_phimId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_phim key.
		///		FK_ve_phim Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_phimId"></param>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		/// <remarks></remarks>
		public TList<Ve> GetByPhimId(TransactionManager transactionManager, System.Int32 _phimId)
		{
			int count = -1;
			return GetByPhimId(transactionManager, _phimId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_phim key.
		///		FK_ve_phim Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_phimId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByPhimId(TransactionManager transactionManager, System.Int32 _phimId, int start, int pageLength)
		{
			int count = -1;
			return GetByPhimId(transactionManager, _phimId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_phim key.
		///		fkVePhim Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_phimId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByPhimId(System.Int32 _phimId, int start, int pageLength)
		{
			int count =  -1;
			return GetByPhimId(null, _phimId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_phim key.
		///		fkVePhim Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_phimId"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByPhimId(System.Int32 _phimId, int start, int pageLength,out int count)
		{
			return GetByPhimId(null, _phimId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_phim key.
		///		FK_ve_phim Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_phimId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public abstract TList<Ve> GetByPhimId(TransactionManager transactionManager, System.Int32 _phimId, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_phong key.
		///		FK_ve_phong Description: 
		/// </summary>
		/// <param name="_phongId"></param>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByPhongId(System.Int32 _phongId)
		{
			int count = -1;
			return GetByPhongId(_phongId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_phong key.
		///		FK_ve_phong Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_phongId"></param>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		/// <remarks></remarks>
		public TList<Ve> GetByPhongId(TransactionManager transactionManager, System.Int32 _phongId)
		{
			int count = -1;
			return GetByPhongId(transactionManager, _phongId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_phong key.
		///		FK_ve_phong Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_phongId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByPhongId(TransactionManager transactionManager, System.Int32 _phongId, int start, int pageLength)
		{
			int count = -1;
			return GetByPhongId(transactionManager, _phongId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_phong key.
		///		fkVePhong Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_phongId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByPhongId(System.Int32 _phongId, int start, int pageLength)
		{
			int count =  -1;
			return GetByPhongId(null, _phongId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_phong key.
		///		fkVePhong Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_phongId"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByPhongId(System.Int32 _phongId, int start, int pageLength,out int count)
		{
			return GetByPhongId(null, _phongId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_phong key.
		///		FK_ve_phong Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_phongId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public abstract TList<Ve> GetByPhongId(TransactionManager transactionManager, System.Int32 _phongId, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_rap key.
		///		FK_ve_rap Description: 
		/// </summary>
		/// <param name="_rapId"></param>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByRapId(System.Int32 _rapId)
		{
			int count = -1;
			return GetByRapId(_rapId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_rap key.
		///		FK_ve_rap Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_rapId"></param>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		/// <remarks></remarks>
		public TList<Ve> GetByRapId(TransactionManager transactionManager, System.Int32 _rapId)
		{
			int count = -1;
			return GetByRapId(transactionManager, _rapId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_rap key.
		///		FK_ve_rap Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_rapId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByRapId(TransactionManager transactionManager, System.Int32 _rapId, int start, int pageLength)
		{
			int count = -1;
			return GetByRapId(transactionManager, _rapId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_rap key.
		///		fkVeRap Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_rapId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByRapId(System.Int32 _rapId, int start, int pageLength)
		{
			int count =  -1;
			return GetByRapId(null, _rapId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_rap key.
		///		fkVeRap Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_rapId"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public TList<Ve> GetByRapId(System.Int32 _rapId, int start, int pageLength,out int count)
		{
			return GetByRapId(null, _rapId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_ve_rap key.
		///		FK_ve_rap Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_rapId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of TicketManager.Entities.Ve objects.</returns>
		public abstract TList<Ve> GetByRapId(TransactionManager transactionManager, System.Int32 _rapId, int start, int pageLength, out int count);
		
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override TicketManager.Entities.Ve Get(TransactionManager transactionManager, TicketManager.Entities.VeKey key, int start, int pageLength)
		{
			return GetByVeId(transactionManager, key.VeId, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_ve index.
		/// </summary>
		/// <param name="_veId"></param>
		/// <returns>Returns an instance of the <see cref="TicketManager.Entities.Ve"/> class.</returns>
		public TicketManager.Entities.Ve GetByVeId(System.Int32 _veId)
		{
			int count = -1;
			return GetByVeId(null,_veId, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_ve index.
		/// </summary>
		/// <param name="_veId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="TicketManager.Entities.Ve"/> class.</returns>
		public TicketManager.Entities.Ve GetByVeId(System.Int32 _veId, int start, int pageLength)
		{
			int count = -1;
			return GetByVeId(null, _veId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_ve index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_veId"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="TicketManager.Entities.Ve"/> class.</returns>
		public TicketManager.Entities.Ve GetByVeId(TransactionManager transactionManager, System.Int32 _veId)
		{
			int count = -1;
			return GetByVeId(transactionManager, _veId, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_ve index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_veId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="TicketManager.Entities.Ve"/> class.</returns>
		public TicketManager.Entities.Ve GetByVeId(TransactionManager transactionManager, System.Int32 _veId, int start, int pageLength)
		{
			int count = -1;
			return GetByVeId(transactionManager, _veId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_ve index.
		/// </summary>
		/// <param name="_veId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="TicketManager.Entities.Ve"/> class.</returns>
		public TicketManager.Entities.Ve GetByVeId(System.Int32 _veId, int start, int pageLength, out int count)
		{
			return GetByVeId(null, _veId, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_ve index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_veId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="TicketManager.Entities.Ve"/> class.</returns>
		public abstract TicketManager.Entities.Ve GetByVeId(TransactionManager transactionManager, System.Int32 _veId, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a TList&lt;Ve&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="TList&lt;Ve&gt;"/></returns>
		public static TList<Ve> Fill(IDataReader reader, TList<Ve> rows, int start, int pageLength)
		{
			NetTiersProvider currentProvider = DataRepository.Provider;
            bool useEntityFactory = currentProvider.UseEntityFactory;
            bool enableEntityTracking = currentProvider.EnableEntityTracking;
            LoadPolicy currentLoadPolicy = currentProvider.CurrentLoadPolicy;
			Type entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;
			
			// advance to the starting row
			for (int i = 0; i < start; i++)
			{
				if (!reader.Read())
				return rows; // not enough rows, just return
			}
			for (int i = 0; i < pageLength; i++)
			{
				if (!reader.Read())
					break; // we are done
					
				string key = null;
				
				TicketManager.Entities.Ve c = null;
				if (useEntityFactory)
				{
					key = new System.Text.StringBuilder("Ve")
					.Append("|").Append((System.Int32)reader[((int)VeColumn.VeId - 1)]).ToString();
					c = EntityManager.LocateOrCreate<Ve>(
					key.ToString(), // EntityTrackingKey
					"Ve",  //Creational Type
					entityCreationFactoryType,  //Factory used to create entity
					enableEntityTracking); // Track this entity?
				}
				else
				{
					c = new TicketManager.Entities.Ve();
				}
				
				if (!enableEntityTracking ||
					c.EntityState == EntityState.Added ||
					(enableEntityTracking &&
					
						(
							(currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
							(currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
						)
					))
				{
					c.SuppressEntityEvents = true;
					c.VeId = (System.Int32)reader[((int)VeColumn.VeId - 1)];
					c.TenVe = (System.String)reader[((int)VeColumn.TenVe - 1)];
					c.MoTa = (reader.IsDBNull(((int)VeColumn.MoTa - 1)))?null:(System.String)reader[((int)VeColumn.MoTa - 1)];
					c.TrangThai = (System.Boolean)reader[((int)VeColumn.TrangThai - 1)];
					c.LoaiVeId = (System.Int32)reader[((int)VeColumn.LoaiVeId - 1)];
					c.RapId = (System.Int32)reader[((int)VeColumn.RapId - 1)];
					c.PhongId = (System.Int32)reader[((int)VeColumn.PhongId - 1)];
					c.PhimId = (System.Int32)reader[((int)VeColumn.PhimId - 1)];
					c.GheId = (System.Int32)reader[((int)VeColumn.GheId - 1)];
					c.Gia = (System.Decimal)reader[((int)VeColumn.Gia - 1)];
					c.EntityTrackingKey = key;
					c.AcceptChanges();
					c.SuppressEntityEvents = false;
				}
				rows.Add(c);
			}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="TicketManager.Entities.Ve"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="TicketManager.Entities.Ve"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, TicketManager.Entities.Ve entity)
		{
			if (!reader.Read()) return;
			
			entity.VeId = (System.Int32)reader[((int)VeColumn.VeId - 1)];
			entity.TenVe = (System.String)reader[((int)VeColumn.TenVe - 1)];
			entity.MoTa = (reader.IsDBNull(((int)VeColumn.MoTa - 1)))?null:(System.String)reader[((int)VeColumn.MoTa - 1)];
			entity.TrangThai = (System.Boolean)reader[((int)VeColumn.TrangThai - 1)];
			entity.LoaiVeId = (System.Int32)reader[((int)VeColumn.LoaiVeId - 1)];
			entity.RapId = (System.Int32)reader[((int)VeColumn.RapId - 1)];
			entity.PhongId = (System.Int32)reader[((int)VeColumn.PhongId - 1)];
			entity.PhimId = (System.Int32)reader[((int)VeColumn.PhimId - 1)];
			entity.GheId = (System.Int32)reader[((int)VeColumn.GheId - 1)];
			entity.Gia = (System.Decimal)reader[((int)VeColumn.Gia - 1)];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="TicketManager.Entities.Ve"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="TicketManager.Entities.Ve"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, TicketManager.Entities.Ve entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.VeId = (System.Int32)dataRow["VeID"];
			entity.TenVe = (System.String)dataRow["TenVe"];
			entity.MoTa = Convert.IsDBNull(dataRow["MoTa"]) ? null : (System.String)dataRow["MoTa"];
			entity.TrangThai = (System.Boolean)dataRow["TrangThai"];
			entity.LoaiVeId = (System.Int32)dataRow["LoaiVeID"];
			entity.RapId = (System.Int32)dataRow["RapID"];
			entity.PhongId = (System.Int32)dataRow["PhongID"];
			entity.PhimId = (System.Int32)dataRow["PhimID"];
			entity.GheId = (System.Int32)dataRow["GheID"];
			entity.Gia = (System.Decimal)dataRow["Gia"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="TicketManager.Entities.Ve"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">TicketManager.Entities.Ve Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		public override void DeepLoad(TransactionManager transactionManager, TicketManager.Entities.Ve entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;

			#region GheIdSource	
			if (CanDeepLoad(entity, "Ghe|GheIdSource", deepLoadType, innerList) 
				&& entity.GheIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.GheId;
				Ghe tmpEntity = EntityManager.LocateEntity<Ghe>(EntityLocator.ConstructKeyFromPkItems(typeof(Ghe), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.GheIdSource = tmpEntity;
				else
					entity.GheIdSource = DataRepository.GheProvider.GetByGheId(transactionManager, entity.GheId);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'GheIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.GheIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.GheProvider.DeepLoad(transactionManager, entity.GheIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion GheIdSource

			#region LoaiVeIdSource	
			if (CanDeepLoad(entity, "Loaive|LoaiVeIdSource", deepLoadType, innerList) 
				&& entity.LoaiVeIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.LoaiVeId;
				Loaive tmpEntity = EntityManager.LocateEntity<Loaive>(EntityLocator.ConstructKeyFromPkItems(typeof(Loaive), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.LoaiVeIdSource = tmpEntity;
				else
					entity.LoaiVeIdSource = DataRepository.LoaiveProvider.GetByLoaiVeId(transactionManager, entity.LoaiVeId);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'LoaiVeIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.LoaiVeIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.LoaiveProvider.DeepLoad(transactionManager, entity.LoaiVeIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion LoaiVeIdSource

			#region PhimIdSource	
			if (CanDeepLoad(entity, "Phim|PhimIdSource", deepLoadType, innerList) 
				&& entity.PhimIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.PhimId;
				Phim tmpEntity = EntityManager.LocateEntity<Phim>(EntityLocator.ConstructKeyFromPkItems(typeof(Phim), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.PhimIdSource = tmpEntity;
				else
					entity.PhimIdSource = DataRepository.PhimProvider.GetByPhimId(transactionManager, entity.PhimId);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PhimIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.PhimIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.PhimProvider.DeepLoad(transactionManager, entity.PhimIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion PhimIdSource

			#region PhongIdSource	
			if (CanDeepLoad(entity, "Phong|PhongIdSource", deepLoadType, innerList) 
				&& entity.PhongIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.PhongId;
				Phong tmpEntity = EntityManager.LocateEntity<Phong>(EntityLocator.ConstructKeyFromPkItems(typeof(Phong), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.PhongIdSource = tmpEntity;
				else
					entity.PhongIdSource = DataRepository.PhongProvider.GetByPhongId(transactionManager, entity.PhongId);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'PhongIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.PhongIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.PhongProvider.DeepLoad(transactionManager, entity.PhongIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion PhongIdSource

			#region RapIdSource	
			if (CanDeepLoad(entity, "Rap|RapIdSource", deepLoadType, innerList) 
				&& entity.RapIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.RapId;
				Rap tmpEntity = EntityManager.LocateEntity<Rap>(EntityLocator.ConstructKeyFromPkItems(typeof(Rap), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.RapIdSource = tmpEntity;
				else
					entity.RapIdSource = DataRepository.RapProvider.GetByRapId(transactionManager, entity.RapId);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'RapIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.RapIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.RapProvider.DeepLoad(transactionManager, entity.RapIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion RapIdSource
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			// Deep load child collections  - Call GetByVeId methods when available
			
			#region LichSuGdkhCollection
			//Relationship Type One : Many
			if (CanDeepLoad(entity, "List<LichSuGdkh>|LichSuGdkhCollection", deepLoadType, innerList)) 
			{
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'LichSuGdkhCollection' loaded. key " + entity.EntityTrackingKey);
				#endif 

				entity.LichSuGdkhCollection = DataRepository.LichSuGdkhProvider.GetByVeId(transactionManager, entity.VeId);

				if (deep && entity.LichSuGdkhCollection.Count > 0)
				{
					deepHandles.Add("LichSuGdkhCollection",
						new KeyValuePair<Delegate, object>((DeepLoadHandle<LichSuGdkh>) DataRepository.LichSuGdkhProvider.DeepLoad,
						new object[] { transactionManager, entity.LichSuGdkhCollection, deep, deepLoadType, childTypes, innerList }
					));
				}
			}		
			#endregion 
			
			
			#region UserIdUserCollection_From_LichSuGdkh
			// RelationshipType.ManyToMany
			if (CanDeepLoad(entity, "List<User>|UserIdUserCollection_From_LichSuGdkh", deepLoadType, innerList))
			{
				entity.UserIdUserCollection_From_LichSuGdkh = DataRepository.UserProvider.GetByVeIdFromLichSuGdkh(transactionManager, entity.VeId);			 
		
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'UserIdUserCollection_From_LichSuGdkh' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.UserIdUserCollection_From_LichSuGdkh != null)
				{
					deepHandles.Add("UserIdUserCollection_From_LichSuGdkh",
						new KeyValuePair<Delegate, object>((DeepLoadHandle< User >) DataRepository.UserProvider.DeepLoad,
						new object[] { transactionManager, entity.UserIdUserCollection_From_LichSuGdkh, deep, deepLoadType, childTypes, innerList }
					));
				}
			}
			#endregion
			
			
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the TicketManager.Entities.Ve object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">TicketManager.Entities.Ve instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">TicketManager.Entities.Ve Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		public override bool DeepSave(TransactionManager transactionManager, TicketManager.Entities.Ve entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			
			#region GheIdSource
			if (CanDeepSave(entity, "Ghe|GheIdSource", deepSaveType, innerList) 
				&& entity.GheIdSource != null)
			{
				DataRepository.GheProvider.Save(transactionManager, entity.GheIdSource);
				entity.GheId = entity.GheIdSource.GheId;
			}
			#endregion 
			
			#region LoaiVeIdSource
			if (CanDeepSave(entity, "Loaive|LoaiVeIdSource", deepSaveType, innerList) 
				&& entity.LoaiVeIdSource != null)
			{
				DataRepository.LoaiveProvider.Save(transactionManager, entity.LoaiVeIdSource);
				entity.LoaiVeId = entity.LoaiVeIdSource.LoaiVeId;
			}
			#endregion 
			
			#region PhimIdSource
			if (CanDeepSave(entity, "Phim|PhimIdSource", deepSaveType, innerList) 
				&& entity.PhimIdSource != null)
			{
				DataRepository.PhimProvider.Save(transactionManager, entity.PhimIdSource);
				entity.PhimId = entity.PhimIdSource.PhimId;
			}
			#endregion 
			
			#region PhongIdSource
			if (CanDeepSave(entity, "Phong|PhongIdSource", deepSaveType, innerList) 
				&& entity.PhongIdSource != null)
			{
				DataRepository.PhongProvider.Save(transactionManager, entity.PhongIdSource);
				entity.PhongId = entity.PhongIdSource.PhongId;
			}
			#endregion 
			
			#region RapIdSource
			if (CanDeepSave(entity, "Rap|RapIdSource", deepSaveType, innerList) 
				&& entity.RapIdSource != null)
			{
				DataRepository.RapProvider.Save(transactionManager, entity.RapIdSource);
				entity.RapId = entity.RapIdSource.RapId;
			}
			#endregion 
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();

			#region UserIdUserCollection_From_LichSuGdkh>
			if (CanDeepSave(entity.UserIdUserCollection_From_LichSuGdkh, "List<User>|UserIdUserCollection_From_LichSuGdkh", deepSaveType, innerList))
			{
				if (entity.UserIdUserCollection_From_LichSuGdkh.Count > 0 || entity.UserIdUserCollection_From_LichSuGdkh.DeletedItems.Count > 0)
				{
					DataRepository.UserProvider.Save(transactionManager, entity.UserIdUserCollection_From_LichSuGdkh); 
					deepHandles.Add("UserIdUserCollection_From_LichSuGdkh",
						new KeyValuePair<Delegate, object>((DeepSaveHandle<User>) DataRepository.UserProvider.DeepSave,
						new object[] { transactionManager, entity.UserIdUserCollection_From_LichSuGdkh, deepSaveType, childTypes, innerList }
					));
				}
			}
			#endregion 
	
			#region List<LichSuGdkh>
				if (CanDeepSave(entity.LichSuGdkhCollection, "List<LichSuGdkh>|LichSuGdkhCollection", deepSaveType, innerList)) 
				{	
					// update each child parent id with the real parent id (mostly used on insert)
					foreach(LichSuGdkh child in entity.LichSuGdkhCollection)
					{
						if(child.VeIdSource != null)
						{
								child.VeId = child.VeIdSource.VeId;
						}

						if(child.UserIdSource != null)
						{
								child.UserId = child.UserIdSource.UserId;
						}

					}

					if (entity.LichSuGdkhCollection.Count > 0 || entity.LichSuGdkhCollection.DeletedItems.Count > 0)
					{
						//DataRepository.LichSuGdkhProvider.Save(transactionManager, entity.LichSuGdkhCollection);
						
						deepHandles.Add("LichSuGdkhCollection",
						new KeyValuePair<Delegate, object>((DeepSaveHandle< LichSuGdkh >) DataRepository.LichSuGdkhProvider.DeepSave,
							new object[] { transactionManager, entity.LichSuGdkhCollection, deepSaveType, childTypes, innerList }
						));
					}
				} 
			#endregion 
				
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region VeChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>TicketManager.Entities.Ve</c>
	///</summary>
	public enum VeChildEntityTypes
	{
		
		///<summary>
		/// Composite Property for <c>Ghe</c> at GheIdSource
		///</summary>
		[ChildEntityType(typeof(Ghe))]
		Ghe,
			
		///<summary>
		/// Composite Property for <c>Loaive</c> at LoaiVeIdSource
		///</summary>
		[ChildEntityType(typeof(Loaive))]
		Loaive,
			
		///<summary>
		/// Composite Property for <c>Phim</c> at PhimIdSource
		///</summary>
		[ChildEntityType(typeof(Phim))]
		Phim,
			
		///<summary>
		/// Composite Property for <c>Phong</c> at PhongIdSource
		///</summary>
		[ChildEntityType(typeof(Phong))]
		Phong,
			
		///<summary>
		/// Composite Property for <c>Rap</c> at RapIdSource
		///</summary>
		[ChildEntityType(typeof(Rap))]
		Rap,
	
		///<summary>
		/// Collection of <c>Ve</c> as OneToMany for LichSuGdkhCollection
		///</summary>
		[ChildEntityType(typeof(TList<LichSuGdkh>))]
		LichSuGdkhCollection,

		///<summary>
		/// Collection of <c>Ve</c> as ManyToMany for UserCollection_From_LichSuGdkh
		///</summary>
		[ChildEntityType(typeof(TList<User>))]
		UserIdUserCollection_From_LichSuGdkh,
	}
	
	#endregion VeChildEntityTypes
	
	#region VeFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;VeColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Ve"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class VeFilterBuilder : SqlFilterBuilder<VeColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the VeFilterBuilder class.
		/// </summary>
		public VeFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the VeFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public VeFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the VeFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public VeFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion VeFilterBuilder
	
	#region VeParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;VeColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Ve"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class VeParameterBuilder : ParameterizedSqlFilterBuilder<VeColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the VeParameterBuilder class.
		/// </summary>
		public VeParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the VeParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public VeParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the VeParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public VeParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion VeParameterBuilder
	
	#region VeSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;VeColumn&gt;"/> class
	/// that is used exclusively with a <see cref="Ve"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class VeSortBuilder : SqlSortBuilder<VeColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the VeSqlSortBuilder class.
		/// </summary>
		public VeSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion VeSortBuilder
	
} // end namespace
